<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改图片位置')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-position-edit" th:object="${tImagePosition}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">图片位置：</label>
                <div class="col-sm-8">
                    <input th:field="*{position}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">图片位置备注：</label>
                <div class="col-sm-8">
                    <input th:field="*{positionRemark}" class="form-control" type="text" readonly>
                </div>
            </div>
            <input type="hidden" name="tImageId" id="tImageId"/>
        </form>
    </div>
    <div class="col-sm-12 select-table table-striped">
        <table id="bootstrap-table"></table>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "fireman/position";
        var prefix_image = ctx + "fireman/image";
        $("#form-position-edit").validate({
            focusCleanup: true
        });

        $(function () {
            var options = {
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                singleSelect: true,
                url: prefix_image + "/list",
                createUrl: prefix_image + "/add",
                updateUrl: prefix_image + "/edit/{id}",
                removeUrl: prefix_image + "/remove",
                exportUrl: prefix_image + "/export",
                modalName: "图片存储",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '主键',
                        visible: false
                    },
                    {
                        title: '图片预览',
                        formatter: function (value, row, index) {
                            return $.table.imageView(row.url);
                        }
                    },
                    {
                        field: 'name',
                        title: '图片名称'
                    }]
            };
            $.table.init(options);
        });

        function submitHandler() {
            if (!$.table.selectColumns("id").length) {
                $.modal.msgError('请选择图片');
                return false;
            }
            $("#tImageId").val($.table.selectColumns("id")[0]);
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-position-edit').serialize());
            }
        }
    </script>
</body>
</html>